from conans import ConanFile, CMake, tools, AutoToolsBuildEnvironment
from conans import tools
import sys
import os
sys.path.append(os.environ.get('PYTHONPATH'))
from pathlib import Path
import shutil


class LibeventConan(ConanFile):
    name = "test"
    version = "1.1.1"
    description = "test for use generator "
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False]}
    default_options = {"shared": False}
    generators = "cmake_find_package"

    def export(self):
        self.copy("libssl.a",dst="")        
    def build(self):
        print("path " + self.source_folder + " is where the package built")
        if tools.os_info.is_windows:
            print("current os windows")
            vcvars = tools.vcvars_command(self)
            print("vcvars_command is ",vcvars)
            self.run("%s &&  cl -v" % (vcvars))

            if tools.os_info.is_cygwin:
                print("cygwin build")
            if tools.get_env("BUILD_ENV") == "msys":
                print("msys build")
            if tools.get_env("BUILD_ENV") == "msvc":
                print("msvc build")
        if tools.os_info.is_linux:
            print("linux build")
    def package(self):
        self.copy("*.a","lib",keep_path=False)


    def package_info(self):
        print("call test package_info")
        self.cpp_info.names["cmake_find_package"] = "test"
        self.cpp_info.libdirs.append('lib') 
        self.cpp_info.libs= ["libssl.a","libssl2.a"]
        self.cpp_info.buildirs = 'pkgsrc'
        self.cpp_info.includedirs.append('include')  
        bin_path = os.path.join(self.package_folder, "bin")
        self.output.info("Appending PATH environment variable: %s" % bin_path)
        self.env_info.PATH.append(bin_path)        
